import { useState, useEffect } from 'react'
import Son from './Son'
const App = function () {
    // 当页面打开后自动发起请求
    useEffect(() => {
        console.log('发起ajax')
        return () => {
            //卸载
        }
    }, [])
    // 更新
    const [count, setCount] = useState(0)
    useEffect(function () {
        console.log('更新完毕:' + count)
    })
    const [value, setValue] = useState("明天作业")
    useEffect(() => {
        console.log('只有value发生改变的时候才执行')
    }, [value])
    // 对某个值更新监听
    return <>
        美好的周五冲作业开启
        <h1>{count}</h1>
        <button onClick={() => setCount(count + 1)}>++</button>
        <h1>{value}</h1>
        <button onClick={
            () => setValue('芜湖,起飞')
        }>修改value</button>
        {count % 2 === 0 && <Son></Son>}

    </>

}

export default App

